
{% extends 'base.html' %}
 
{% block title %}
百度云下载工具
{% endblock %}
 
{% block content %}
	<br />
	<div class="container">
		<ol id="breadcrumb" class="breadcrumb">
			<!--  breadcrumb  -->
		</ol>

		<div class="container">
			<h4>文件列表</h4>
			<div id="file_list" class="list-group">
				<!--  list  -->
			</div>

		</div>
	</div>
	
	
	
{% endblock %}

{% block js %}
	<script>
	$(document).ready(function(){
		{% autoescape false %}
		var file = {{ file }};
		{% endautoescape %}
		var file_href = "";

		if (file.length > 0){
			for(var i=0;i<file.length;i++){
				file_href += '/' + file[i];
				if (file_href == '/'){
					file_href = '';
					$("#breadcrumb").append("<li><a href=\"/disk\">首页</a></li>");
				}else{
					if (i == (file.length - 1)){
						$("#breadcrumb").append("<li>" + file[i] + "</a></li>");
					}else{
						$("#breadcrumb").append("<li><a href=\"/disk?file=" + file_href + "\">" + file[i] + "</a></li>");
					}
				}
			}
		}

		$.ajax({
			type: "POST",
			url: '/disk',
			data: {
				'file': file_href == '' ? '/' : file_href
			},
			success: function(result) {
				if (result.success == 1) {
					for(var i=0;i<result.file_list.length;i++){
						$("#file_list").append("<a href=\"" + result.file_list[i].href + "\" class=\"list-group-item\">" + result.file_list[i].name + "</a>");
					}
				}
			}
		});
    });
	</script>
{% endblock %}